package com.tyk.bookstore.front.cart.service.impl;


import com.tyk.bookstore.front.cart.model.dto.Cart4OrderDto;
import com.tyk.bookstore.front.cart.model.entity.CartDo;
import com.tyk.bookstore.front.cart.repository.CartRepository;
import com.tyk.bookstore.front.cart.service.ShoppingCartApiService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 * @author tyk
 * @description 购物车对内接口
 */
@Service
@RequiredArgsConstructor
public class CartApiServiceImpl implements ShoppingCartApiService {

    private final CartRepository cartRepository;

    @Override
    public List<Cart4OrderDto> getCart4OrderDtoListCheckedByMemberId(Long memberId) {
        return cartRepository.selectCart4OrderDtoListCheckedByMemberId(memberId);
    }

    @Override
    public void deleteByBookIdList(Set<Long> bookIdSet, Long memberId) {
        cartRepository.delete1In1Eq(
                CartDo::getBookId, bookIdSet,
                CartDo::getMemberId, memberId,
                CartDo.class
        );
    }
}
